/*
 * Task_Timer.c
 *
 *  Created on: 2018-3-24
 *      Author: root
 */

#ifndef TASK_TIMER_C_
#define TASK_TIMER_C_
#include "sys.h"
#include "Task_Timer.h"
#include "stddef.h"
#include <unistd.h>
#include "meter.h"
#include <stdio.h>
//用线程实现一个简单的定时器
TTaskInfo Info_Task_Timer;
#define TIMER_1S   1
#define TIMER_300MS  300
#define TIMER_1000MS  1000
void timer_1000MS(void)//300毫秒一次
{
	addtime_meter1000(TIMER_1000MS);
}
void timer_300MS(void)//300毫秒一次
{
//	addtime_meter(TIMER_300MS);
}
void timer_1s(void)//1秒一次
{
//	addtime_tcu(TIMER_1S);
}
OS_TaskRet Task_Timer123(void *arg)
{
	u32 i=0;
	while(1)
	{
		usleep(100000);//100ms
		i++;
		if(i%3==0)
			timer_300MS();
        if(i%10==0)
    	{
        	timer_1s();
        	timer_1000MS();

    	}

	}

	return NULL;
}

void initTask_Timer_mt(void)
{
    printf("\r\n\r\n\r\n  initTask_Timer_mt  \r\n\r\n ");
	Info_Task_Timer.Prio = 0;
	Info_Task_Timer.Stk = NULL;
	Info_Task_Timer.Stk_Size = 0;

    os_create_task(Task_Timer123, NULL, &Info_Task_Timer);
}

#endif /* TASK_TIMER_C_ */
